package com.rayboo.vo;

/**
 * 
 * PageResult
 * 
 * @author ray
 * @date 2016年9月8日 下午8:14:57
 *
 */
public class PageResult {
    private boolean success = true;
    private Object data;
    private Integer total=0;
    private Integer pageSize=20;
    private String msg = "操作完成";
    private Integer result=1;//返回状态码（1为成功，其他为失败）


    public static PageResult genSuccess() {
        return new PageResult().setSuccess(true);
    }

    public static PageResult genSuccess(String msg) {
        return new PageResult().setSuccess(true).setMsg(msg);
    }

    public static PageResult genSuccess(Object data) {
        return new PageResult().setSuccess(true).setData(data);
    }

    public static PageResult genSuccess(Object data,String msg) {
        return new PageResult().setSuccess(true).setData(data).setMsg(msg);
    }

    public static PageResult genSuccess(Object data, Integer total) {
        return new PageResult().setSuccess(true).setData(data).setTotal(total);
    }

    public static PageResult genSuccess(Object data, Integer total, Integer pageSize) {
        return new PageResult().setSuccess(true).setData(data).setTotal(total).setPageSize(pageSize);
    }

    public static PageResult genFail(String msg) {
        return new PageResult().setSuccess(false).setMsg(msg);
    }

    public static PageResult genFail(String msg,Integer result) {
        return new PageResult().setSuccess(false).setMsg(msg).setResult(result);
    }

    public static PageResult genSuccess(String msg, Integer result) {
        return new PageResult().setSuccess(true).setMsg(msg).setResult(result);
    }

    public boolean isSuccess() {
        return success;
    }

    public PageResult setSuccess(boolean success) {
        this.success = success;
        return this;
    }

    public Object getData() {
        return data;
    }

    public PageResult setData(Object data) {
        this.data = data;
        return this;
    }

    public String getMsg() {
        return msg;
    }

    public PageResult setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public Integer getTotal() {
        return total;
    }

    public PageResult setTotal(Integer total) {
        this.total = total;
        return this;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public PageResult setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
        return this;
    }

    public Integer getResult() {
        return result;
    }

    public PageResult setResult(Integer result) {
        this.result = result;
        return this;
    }
}
